package com.zk.shop.servlet.goods;

import com.zk.shop.service.GoodsService;
import com.zk.shop.service.Impl.GoodsServicesImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @version 1.0
 * @ClassName DeleteGoodsServlet
 * @Description TODO
 * @Author 关轶阳
 * @Date 2019/9/30 0030 上午 10:53
 */
@WebServlet("/DeleteGoodsServlet")
public class DeleteGoodsServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int goodsId= Integer.parseInt(request.getParameter("goodsId"));
        GoodsService goodsService=new GoodsServicesImpl();
        boolean flag=goodsService.deleteGoods(goodsId);
        PrintWriter out =response.getWriter();
        if(flag){
            out.print("删除成功");
        }else{
            out.print("删除失败");
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
